CSharpTest.Net
EnumerateRange Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : EnumerateRange Method

start
end

Glossary Item Box

Inclusivly enumerates from start value to stop value

Syntax

Visual Basic (Declaration) 
Public Function EnumerateRange( _
   ByVal start As T, _
   ByVal end As T _
) As IEnumerable(Of T)
C# 
public IEnumerable<T> EnumerateRange( 
   T start,
   T end
)

Parameters

start
end

Example

Library/Library.Test/TestBTreeList.cs

C#Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer);
for (int i = 0; i < 100; i++)
    Assert.IsTrue(data.TryAddItem(i));

int ix = 0;
foreach (int kv in data.EnumerateRange(-500, 5000))
    Assert.AreEqual(ix++, kv);
Assert.AreEqual(100, ix);

foreach (
    KeyValuePair<int, int> range in
        new Dictionary<int, int> {{6, 25}, {7, 25}, {8, 25}, {9, 25}, {22, 25}, {28, 28}})
{
    ix = range.Key;
    foreach (int kv in data.EnumerateRange(ix, range.Value))
        Assert.AreEqual(ix++, kv);
    Assert.AreEqual(range.Value, ix - 1);
}
VB.NETCopy Code
Dim data As New BTreeList(Of Integer)(Comparer)
Dim i As Integer = 0
While i < 100
    Assert.IsTrue(data.TryAddItem(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim ix As Integer = 0
For Each kv As Integer In data.EnumerateRange(-500, 5000)
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1), kv)
Next
Assert.AreEqual(100, ix)

For Each range As KeyValuePair(Of Integer, Integer) In New Dictionary(Of Integer, Integer)() From { _
    {6, 25}, _
    {7, 25}, _
    {8, 25}, _
    {9, 25}, _
    {22, 25}, _
    {28, 28} _
}
    ix = range.Key
    For Each kv As Integer In data.EnumerateRange(ix, range.Value)
        Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1), kv)
    Next
    Assert.AreEqual(range.Value, ix - 1)
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys